package test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
//import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;

public class DWCatalog extends DWExportXML {
	
	private String catalogId;

	public DWCatalog (String xmlFile, String catalogId) {
		super (xmlFile);
		this.catalogId = catalogId;
	}
	
	public void StartXmlOutput() {
		super.StartXmlOutput();
		Attribute attribute = eventFactory.createAttribute("","","catalog-id", catalogId);
		//List <?>attributeList = Arrays.asList(attribute);
		List <Attribute>attributeList = new ArrayList<Attribute>(); //		Arrays.asList(attribute);
		attributeList.add(attribute);
		List <?>nodeList = Arrays.asList();
		attribute = eventFactory.createAttribute("","","xmlns", "http://www.demandware.com/xml/impex/catalog/2006-10-31");
		attributeList.add(attribute); //(attribute);
		//xmlns="http://www.demandware.com/xml/impex/catalog/2006-10-31"
		
		// Create catalog open tag
		StartElement startElement = eventFactory.createStartElement("","", "catalog",attributeList.iterator(),nodeList.iterator());
		//configStartElement.
		XMLEvent end = eventFactory.createDTD("\n");
		
		try {
			eventWriter.add(startElement);
			eventWriter.add(end);
		} catch (Exception e) {
			System.err.println("Exception DWCatalog.java StartXmlOutput()");
			System.out.println(e);
		}
	}
	
	public void FinishXmlOutput() {
		EndElement eElement = eventFactory.createEndElement("", "", "catalog");
		try {
			eventWriter.add(eventFactory.createDTD("\n"));
			eventWriter.add(eElement);
		} catch (Exception e) {
			System.err.println("Exception DWCatalog.java FinishXmlOutput()");
			System.out.println(e);
		}
		super.FinishXmlOutput();
	}
}
